<template>
  <div class="search-history"> 
    <van-cell title="历史"  :border=false>
      <span v-if="isdel">删除全部</span>
      <span v-if="isdel"  @click="setdel">   取消</span>
      <van-icon name="delete-o" v-else @click="setdel"/>
    </van-cell>
    <van-cell :title="item" icon="search" v-for="(item,index) in searchtextlist" :key="index">
      <van-icon name="close" v-if="isdel" />
    </van-cell>
    </div>
</template>

<script>
export default {
  data(){
    return{
       isdel:false,//删除按钮显隐状态
       searchtextlist:[]
    }
  },
  props:{
     
     searchtext:{
       type:String,
       require:true
     }
  },
  created(){
       this.searchtextlist=JSON.parse(localStorage.getItem('HEIMA_searchtextlist'))
  },
  methods:{
    setdel(){
      this.isdel=!this.isdel
    }
  }

};
</script>

<style>
</style>